package com.ml.mall.utils;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ml.mall.bean.req.vo.OrderMailTemplateVO;
import com.ml.mall.bean.res.order.OrderQueryOneRes;
import com.ml.mall.bean.vo.coupon.CupponDetailVO;
import com.ml.mall.entity.coupon.SysCouponRecord;
import com.ml.mall.entity.detail.SysOrderDetail;
import com.ml.mall.entity.msg.SysOrderMsg;
import com.ml.mall.entity.supplier.SysOrderSupplier;
import com.ml.mall.entity.sys.SysUser;
import com.ml.mall.enums.RetStatusNum;
import com.ml.mall.exception.BizException;
import com.ml.mall.security.JwtUtil;
import com.ml.mall.service.coupon.SysCouponRecordService;
import com.ml.mall.service.coupon.SysCouponService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.naming.NamingEnumeration;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author :pl
 * @version :1.0
 * @description :邮箱模板
 * @date :2021/8/12
 **/
public class MailTemplateUtils {
    //买家订单发送的邮件信息
    public static StringBuilder MailTeplate(OrderMailTemplateVO orderMailTemplateVO,SysOrderMsg sysOrderMsg){
        StringBuilder sb=new StringBuilder();
        sb.append("<div style='width: 1000px; margin: auto; text-align: left;font-family: 'Helvetica', sans-serif;'>");
        sb.append("<img src=mainPicUrl style=\"width: 100%; height: 200px; margin: -8px;\">\n" +
                "\t\t<div style=\"border-bottom: solid 0.5px #e1e6ed; padding-bottom: 50px; width: 90%; margin: auto;\">\n" +
                "\t\t\t<div style=\"width: 70%;\">\n" +
                "\t\t\t\t<span style=\"font-weight: bold; font-size: 32pt; color: #06375b;\">\n" +
                "\t\t\t\t\tPurchase order payment \n" +
                "\t\t\t\t\t<span style=\"color: #54af9a;\">done</span>!\n" +
                "\t\t\t\t</span>\n" +
                "\t\t\t</div>\n" +
                "\t\t</div>");

        sb.append("<div style=\"width: 90%; margin: auto; padding-top: 20px;\">");
        sb.append("<p>Hi <strong>USERNAME ,</strong></p>\n" +
                "\t\t\t<br>\n" +
                "\t\t\t<p>You have made a payment of <strong>"+orderMailTemplateVO.getAllQuantity()+"</strong> \n" +
                "\t\t\tfor purchase order \n" +
                "\t\t\t<strong>\n" +
                "\t\t\t"+orderMailTemplateVO.getOid()+"\n" +
                "\t\t\t</strong> \n" +
                "\t\t\twith details as below:\n" +
                "\t\t\t</p>");

        //卖家订单
        if(null != orderMailTemplateVO.getOrderArr() && orderMailTemplateVO.getOrderArr().size()>0){
            orderMailTemplateVO.getOrderArr().stream().forEach(it->{
                sb.append("<div style=\"background-color: #EFF2F4\">");
                sb.append("<h4>Products</h4>\n" +
                        "\t\t\t\t<div class=\"supplier-products-info\">\n" +
                        "\t\t\t\t\t<div style=\"display: inline-block; width: 25%;\">\n" +
                        "\t\t\t\t\t\t<strong>"+it.getSupplierCompanyName()+"</strong>\n" +
                        "\t\t\t\t\t</div>\n" +
                        "\t\t\t\t</div>");
                sb.append("<div class=\"supplier-product-table\" style=\"padding-top: 20px; padding-bottom: 30px; border-bottom: solid 0.5px #D4DAE6;\">");
                sb.append("<table style=\"width: 100%; border-radius: 5px; border-collapse: collapse;\">");
                sb.append("<tbody>");
                    sb.append("<tr>\n" +
                            "\t\t\t\t\t\t\t\t<th style=\"width: 15%; padding: 5px 10px;\">Image</th>\n" +
                            "\t\t\t\t\t\t\t\t<th style=\"width: 40%;text-align: left;\">Product Name</th>\n" +
                            "\t\t\t\t\t\t\t\t<th style=\"width: 10%;text-align: center;\">Quantity</th>\n" +
                            "\t\t\t\t\t\t\t\t<th style=\"width: 15%;text-align: right;\">Unit Price</th>\n" +
                            "\t\t\t\t\t\t\t\t<th style=\"width: 10%;text-align: right; padding-right: 10px;\">Total</th>\n" +
                            "\t\t\t\t\t\t\t</tr>");
                    if(null != it.getOrderDetailArr() && it.getOrderDetailArr().size()>0){
                        it.getOrderDetailArr().stream().forEach(od->{
                            sb.append("<tr style=\"background-color: #DCE5F2; border-radius: 10px;\">\n" +
                                    "\t\t\t\t\t\t\t\t<td style=\"border: none; padding: 10px 0 10px 10px;\">\n" +
                                    "\t\t\t\t\t\t\t\t\t<img src=http://res.airenaprocure.com/static"+od.getPicUrl()+" style=\"width: 75px; height: 75px;\">\n" +
                                    "\t\t\t\t\t\t\t\t</td>\n" +
                                    "\t\t\t\t\t\t\t\t<td style=\"border: none;\">\n" +
                                    "\t\t\t\t\t\t\t\t\t"+od.getVariantName()+"\n" +
                                    "\t\t\t\t\t\t\t\t</td>\n" +
                                    "\t\t\t\t\t\t\t\t<td style=\"border: none; text-align: center;\">\n" +
                                    "\t\t\t\t\t\t\t\t\t"+od.getQuantity()+"\n" +
                                    "\t\t\t\t\t\t\t\t</td>\n" +
                                    "\t\t\t\t\t\t\t\t<td style=\"border: none; text-align: right;\">\n" +
                                    "\t\t\t\t\t\t\t\t\t<div style=\"padding-bottom: 5px;\">RM "+od.getPrice()+"</div>\n" +
                                    "\t\t\t\t\t\t\t\t\t<div style=\"padding-bottom: 5px;\">RM "+od.getSellPrice()+"</div>\n" +
                                    "\t\t\t\t\t\t\t\t\t<div>RM "+od.getBuyunit()+"</div>\n" +
                                    "\t\t\t\t\t\t\t\t</td>\n" +
                                    "\t\t\t\t\t\t\t\t<td style=\"border: none; text-align: right; padding-right: 10px;\">\n" +
                                    "\t\t\t\t\t\t\t\t\tRM "+od.getAllmoney()+"\n" +
                                    "\t\t\t\t\t\t\t\t</td>\n" +
                                    "\t\t\t\t\t\t\t</tr>");
                        });
                    }
                    sb.append("<tr style=\"border-radius: 10px; font-weight: bold;\">\n" +
                            "\t\t\t\t\t\t\t\t<td colspan=\"4\" style=\"text-align: right;\">\n" +
                            "\t\t\t\t\t\t\t\t\t<div>Delivery Fee (Delivered by [ logistic_company_name ]) :</div>\n" +
                            "\t\t\t\t\t\t\t\t</td>\n" +
                            "\t\t\t\t\t\t\t\t<td style=\"text-align: right; font-size: 13px; padding-right: 10px; padding-bottom: 10px;\">\n" +
                            "\t\t\t\t\t\t\t\t\t<div class=\"delivery_fee\">\n" +
                            "\t\t\t\t\t\t\t\t\t\tRM "+(it.getDeliveryFee()==null?"":it.getDeliveryFee())+"\n" +
                            "\t\t\t\t\t\t\t\t\t</div>\n" +
                            "\t\t\t\t\t\t\t\t</td>\n" +
                            "\t\t\t\t\t\t\t</tr>");
                if(null != it.getCupponVOList() && it.getCupponVOList().size()>0){
                    it.getCupponVOList().stream().forEach(itt->{
                        sb.append("<tr style=\"border-radius: 10px; font-weight: bold;\">\n" +
                                "\t\t\t\t\t\t\t\t<td colspan=\"4\" style=\"text-align: right;\">\n" +
                                "\t\t\t\t\t\t\t\t\t<div style=\"padding: 5px\">\n" +
                                "\t\t\t\t\t\t\t\t\t\t<div style=\"display: inline-block; width: 100px; font-size: 13px; padding-left: 5px; float: right; vertical-align: middle; line-height: 30px;\">\n" +
                                "\t\t\t\t\t\t\t\t\t\t\t("+itt.getSysCoupon().getDescription()+")\n" +
                                "\t\t\t\t\t\t\t\t\t\t</div>\n" +
                                "\t\t\t\t\t\t\t\t\t\t<div style=\"background-color: #2C84EA; border-radius: 5px; width: 100px; font-size: 13px; padding: 5px; float: right; display: inline-block;\">\n" +
                                "\t\t\t\t\t\t\t\t\t\t\t<span style=\"color: white;\">"+itt.getSysCoupon().getCouponName()+"</span>\n" +
                                "\t\t\t\t\t\t\t\t\t\t</div>\n" +
                                "\t\t\t\t\t\t\t\t\t</div>\n" +
                                "\t\t\t\t\t\t\t\t</td>\n" +
                                "\t\t\t\t\t\t\t\t<td style=\"text-align: right; font-size: 13px; padding-right: 10px; padding-bottom: 10px;\">\n" +
                                "\t\t\t\t\t\t\t\t\t<div>\n" +
                                "\t\t\t\t\t\t\t\t\t\t- RM "+itt.getSysCoupon().getCouponMoney()+"\n" +
                                "\t\t\t\t\t\t\t\t\t</div>\n" +
                                "\t\t\t\t\t\t\t\t</td>\n" +
                                "\t\t\t\t\t\t\t</tr>");
                    });
                }
                sb.append("</tbody>");
                sb.append("</table>");
                sb.append("</div>");
                sb.append("</div>");
            });
        }


        sb.append("<div style=\"background-color: #EFF2F4;padding-bottom: 20px;\">");
            sb.append("<table style=\"width: 100%; border-radius: 5px; border-collapse: collapse;\">");
                sb.append("<tbody>");
                    sb.append("<tr>");
                        sb.append("<td style=\"width: 45%;text-align: left\">\n" +
                                "\t\t\t\t\t\t\t\t<div style=\"padding-bottom: 5px\">\n" +
                                "\t\t\t\t\t\t\t\t\t<span style=\"font-weight: bold;\">Delivery Note</span>\n" +
                                "\t\t\t\t\t\t\t\t</div>\n" +
                                "\t\t\t\t\t\t\t\t<div style=\"padding-bottom: 10px\">\n" +
                                "\t\t\t\t\t\t\t\t\t<textarea rows=\"5\" cols=\"60\" readonly=\"\"style=\"border-radius: 5px; resize: none;\">"+(sysOrderMsg.getBuyerMsg()==null?"":sysOrderMsg.getBuyerMsg())+"</textarea>\n" +
                                "\t\t\t\t\t\t\t\t</div>\n" +
                                "\t\t\t\t\t\t\t</td>");

                        sb.append("<th style=\"width: 55%; text-align: right;\">");
                            sb.append("<table style=\"width: 100%; font-size:13px\">");
                                sb.append("<tbody>");
                                    sb.append("<tr>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%; text-align: left;\">Sub total</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 5%\">:</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 45%\"></td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%;\">RM "+orderMailTemplateVO.getSubFee()+"</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t</tr>");
                                    //尾部中间需要循环的优惠券
                                    if(null != orderMailTemplateVO.getCupponVOList() && orderMailTemplateVO.getCupponVOList().size()>0){
                                        orderMailTemplateVO.getCupponVOList().stream().forEach(it->{
                                            sb.append("<tr>\n" +
                                                    "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%; text-align: left;\">Coupon</td>\n" +
                                                    "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 5%\">:</td>\n" +
                                                    "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 45%\">\n" +
                                                    "\t\t\t\t\t\t\t\t\t\t\t\t<div style=\"padding-bottom: 5px\">\n" +
                                                    "\t\t\t\t\t\t\t\t\t\t\t\t\t<div\n" +
                                                    "\t\t\t\t\t\t\t\t\t\t\t\t\t\tstyle=\"display: inline-block; width: 100px; font-size: 13px; padding-left: 5px; float: right; vertical-align: middle; line-height: 30px;\">\n" +
                                                    "\t\t\t\t\t\t\t\t\t\t\t\t\t\t("+it.getSysCoupon().getDescription()+")\n" +
                                                    "\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n" +
                                                    "\t\t\t\t\t\t\t\t\t\t\t\t\t<div style=\"background-color: #F5537F; border-radius: 5px; width: 100px; font-size: 13px; padding: 5px; float: right; display: inline-block;\">\n" +
                                                    "\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span style=\"color: white;\">"+it.getSysCoupon().getCouponName()+"</span>\n" +
                                                    "\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n" +
                                                    "\t\t\t\t\t\t\t\t\t\t\t\t</div>\n" +
                                                    "\t\t\t\t\t\t\t\t\t\t\t</td>\n" +
                                                    "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%;\">- RM "+it.getSysCoupon().getCouponMoney()+"</td>\n" +
                                                    "\t\t\t\t\t\t\t\t\t\t</tr>");
                                        });
                                    }
                                    sb.append("<tr>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%; text-align: left;\">Delivery Fee</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 5%\">:</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 45%\"></td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%;\">RM "+(orderMailTemplateVO.getDeliveryFee()==null?"":orderMailTemplateVO.getDeliveryFee())+"</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t</tr>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t<tr>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%; text-align: left;\">Shipping Coupon</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 5%\">:</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 45%\"></td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%;\">- RM [shipping_coupon]</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t</tr>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t<tr>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%; text-align: left;\">Adjustment</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 5%\">:</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 45%\"></td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%;\">RM "+orderMailTemplateVO.getAdaptFee()+"</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t</tr>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t<tr>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%; text-align: left;\">Credit</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 5%\">:</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 45%\"></td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%;\">- RM "+orderMailTemplateVO.getSubFee()+"</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t</tr>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t<tr>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%; text-align: left;\">Total (Incl. Tax)</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 5%\">:</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 45%\"></td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%;\">RM "+orderMailTemplateVO.getTruePay()+"</td>\n" +
                                            "\t\t\t\t\t\t\t\t\t\t</tr>");
                                sb.append("</tbody>");
                            sb.append("</table>");
                        sb.append("</th>");
                    sb.append("</tr>");
                sb.append("</tbody>");
            sb.append("</table>");
        sb.append("</div>");
        sb.append("<br>\n" +
                "\t\t\t<a href=SYSTEM_URL style=\"color: #2c84ea; font-weight: bold;\"> system_url </a>\n" +
                "\t\t\t<br>\n" +
                "\t\t\t<p>Need help? Contact \n" +
                "\t\t\t\t<strong> contact_no </strong> or send email to \n" +
                "\t\t\t\t<strong> general_email </strong> \n" +
                "\t\t\t\tfor system enquiry.\n" +
                "\t\t\t</p>\n" +
                "\t\t\t<br>\n" +
                "\t\t\t<p>Best regards,<br><strong>Airena Procure System</strong></p>");
        sb.append("</div>");
        sb.append("</div>");
        return sb;
    }




    //卖家订单发送的邮件信息
    public static StringBuilder MailSupplierTeplate(SysOrderSupplier sysOrderSupplier, List<SysOrderDetail> sysOrderDetails, List<CupponDetailVO> cupponDetailVOList, SysOrderMsg sysOrderMsg) {
        StringBuilder sb=new StringBuilder();
        sb.append("<div style='width: 1000px; margin: auto; text-align: left;font-family: 'Helvetica', sans-serif;'>");
        sb.append("<img src=mainPicUrl style=\"width: 100%; height: 200px; margin: -8px;\">\n" +
                "\t\t<div style=\"border-bottom: solid 0.5px #e1e6ed; padding-bottom: 50px; width: 90%; margin: auto;\">\n" +
                "\t\t\t<div style=\"width: 70%;\">\n" +
                "\t\t\t\t<span style=\"font-weight: bold; font-size: 32pt; color: #06375b;\">\n" +
                "\t\t\t\t\tPurchase order payment \n" +
                "\t\t\t\t\t<span style=\"color: #54af9a;\">done</span>!\n" +
                "\t\t\t\t</span>\n" +
                "\t\t\t</div>\n" +
                "\t\t</div>");

        sb.append("<div style=\"width: 90%; margin: auto; padding-top: 20px;\">");
        sb.append("<p>Hi <strong>USERNAME ,</strong></p>\n" +
                "\t\t\t<br>\n" +
                "\t\t\t<p>You have made a payment of <strong> AllQuantity </strong> \n" +
                "\t\t\tfor purchase order \n" +
                "\t\t\t<strong>\n" +
                "\t\t\t"+sysOrderSupplier.getSupplierOid()+"\n" +
                "\t\t\t</strong> \n" +
                "\t\t\twith details as below:\n" +
                "\t\t\t</p>");

        //卖家订单
        sb.append("<div style=\"background-color: #EFF2F4\">");
        sb.append("<h4>Products</h4>\n" +
                "\t\t\t\t<div class=\"supplier-products-info\">\n" +
                "\t\t\t\t\t<div style=\"display: inline-block; width: 25%;\">\n" +
                "\t\t\t\t\t\t<strong>"+sysOrderSupplier.getSupplierCode()+"</strong>\n" +
                "\t\t\t\t\t</div>\n" +
                "\t\t\t\t</div>");
        sb.append("<div class=\"supplier-product-table\" style=\"padding-top: 20px; padding-bottom: 30px; border-bottom: solid 0.5px #D4DAE6;\">");
        sb.append("<table style=\"width: 100%; border-radius: 5px; border-collapse: collapse;\">");
        sb.append("<tbody>");
        sb.append("<tr>\n" +
                "\t\t\t\t\t\t\t\t<th style=\"width: 15%; padding: 5px 10px;\">Image</th>\n" +
                "\t\t\t\t\t\t\t\t<th style=\"width: 40%;text-align: left;\">Product Name</th>\n" +
                "\t\t\t\t\t\t\t\t<th style=\"width: 10%;text-align: center;\">Quantity</th>\n" +
                "\t\t\t\t\t\t\t\t<th style=\"width: 15%;text-align: right;\">Unit Price</th>\n" +
                "\t\t\t\t\t\t\t\t<th style=\"width: 10%;text-align: right; padding-right: 10px;\">Total</th>\n" +
                "\t\t\t\t\t\t\t</tr>");
        Integer AllQuantity=0;
        if(null != sysOrderDetails && sysOrderDetails.size()>0) {
            for (SysOrderDetail od : sysOrderDetails) {
                BigDecimal allMoney = od.getOriginalSellPrice() == null ? od.getOriginalPrice().multiply(new BigDecimal(od.getQuantity())) : od.getOriginalSellPrice().multiply(new BigDecimal(od.getQuantity()));
                AllQuantity += od.getQuantity();
                sb.append("<tr style=\"background-color: #DCE5F2; border-radius: 10px;\">\n" +
                        "\t\t\t\t\t\t\t\t<td style=\"border: none; padding: 10px 0 10px 10px;\">\n" +
                        "\t\t\t\t\t\t\t\t\t<img src=http://res.airenaprocure.com/static" + od.getPicUrl() + " style=\"width: 75px; height: 75px;\">\n" +
                        "\t\t\t\t\t\t\t\t</td>\n" +
                        "\t\t\t\t\t\t\t\t<td style=\"border: none;\">\n" +
                        "\t\t\t\t\t\t\t\t\t" + od.getVariantName() + "\n" +
                        "\t\t\t\t\t\t\t\t</td>\n" +
                        "\t\t\t\t\t\t\t\t<td style=\"border: none; text-align: center;\">\n" +
                        "\t\t\t\t\t\t\t\t\t" + od.getQuantity() + "\n" +
                        "\t\t\t\t\t\t\t\t</td>\n" +
                        "\t\t\t\t\t\t\t\t<td style=\"border: none; text-align: right;\">\n" +
                        "\t\t\t\t\t\t\t\t\t<div style=\"padding-bottom: 5px;\">RM " + od.getOriginalPrice() + "</div>\n" +
                        "\t\t\t\t\t\t\t\t\t<div style=\"padding-bottom: 5px;\">RM " + od.getOriginalSellPrice() + "</div>\n" +
                        "\t\t\t\t\t\t\t\t\t<div>RM " + od.getBuyunit() + "</div>\n" +
                        "\t\t\t\t\t\t\t\t</td>\n" +
                        "\t\t\t\t\t\t\t\t<td style=\"border: none; text-align: right; padding-right: 10px;\">\n" +
                        "\t\t\t\t\t\t\t\t\tRM " + allMoney + "\n" +
                        "\t\t\t\t\t\t\t\t</td>\n" +
                        "\t\t\t\t\t\t\t</tr>");
            }
        }
        String allQuantity = sb.toString().replaceAll("AllQuantity", AllQuantity.toString());
        sb=new StringBuilder(allQuantity);
        sb.append("<tr style=\"border-radius: 10px; font-weight: bold;\">\n" +
                "\t\t\t\t\t\t\t\t<td colspan=\"4\" style=\"text-align: right;\">\n" +
                "\t\t\t\t\t\t\t\t\t<div>Delivery Fee (Delivered by [ logistic_company_name ]) :</div>\n" +
                "\t\t\t\t\t\t\t\t</td>\n" +
                "\t\t\t\t\t\t\t\t<td style=\"text-align: right; font-size: 13px; padding-right: 10px; padding-bottom: 10px;\">\n" +
                "\t\t\t\t\t\t\t\t\t<div class=\"delivery_fee\">\n" +
                "\t\t\t\t\t\t\t\t\t\tRM "+(sysOrderSupplier.getDeliveryFee()==null?"":sysOrderSupplier.getDeliveryFee())+"\n" +
                "\t\t\t\t\t\t\t\t\t</div>\n" +
                "\t\t\t\t\t\t\t\t</td>\n" +
                "\t\t\t\t\t\t\t</tr>");
        if(null != cupponDetailVOList && cupponDetailVOList.size()>0){
            for (CupponDetailVO itt : cupponDetailVOList) {
                sb.append("<tr style=\"border-radius: 10px; font-weight: bold;\">\n" +
                        "\t\t\t\t\t\t\t\t<td colspan=\"4\" style=\"text-align: right;\">\n" +
                        "\t\t\t\t\t\t\t\t\t<div style=\"padding: 5px\">\n" +
                        "\t\t\t\t\t\t\t\t\t\t<div style=\"display: inline-block; width: 100px; font-size: 13px; padding-left: 5px; float: right; vertical-align: middle; line-height: 30px;\">\n" +
                        "\t\t\t\t\t\t\t\t\t\t\t(" + itt.getSysCoupon().getDescription() + ")\n" +
                        "\t\t\t\t\t\t\t\t\t\t</div>\n" +
                        "\t\t\t\t\t\t\t\t\t\t<div style=\"background-color: #2C84EA; border-radius: 5px; width: 100px; font-size: 13px; padding: 5px; float: right; display: inline-block;\">\n" +
                        "\t\t\t\t\t\t\t\t\t\t\t<span style=\"color: white;\">" + itt.getSysCoupon().getCouponName() + "</span>\n" +
                        "\t\t\t\t\t\t\t\t\t\t</div>\n" +
                        "\t\t\t\t\t\t\t\t\t</div>\n" +
                        "\t\t\t\t\t\t\t\t</td>\n" +
                        "\t\t\t\t\t\t\t\t<td style=\"text-align: right; font-size: 13px; padding-right: 10px; padding-bottom: 10px;\">\n" +
                        "\t\t\t\t\t\t\t\t\t<div>\n" +
                        "\t\t\t\t\t\t\t\t\t\t- RM " + itt.getSysCoupon().getCouponMoney() + "\n" +
                        "\t\t\t\t\t\t\t\t\t</div>\n" +
                        "\t\t\t\t\t\t\t\t</td>\n" +
                        "\t\t\t\t\t\t\t</tr>");
            }
        }
        sb.append("</tbody>");
        sb.append("</table>");
        sb.append("</div>");
        sb.append("</div>");

        sb.append("<div style=\"background-color: #EFF2F4;padding-bottom: 20px;\">");
        sb.append("<table style=\"width: 100%; border-radius: 5px; border-collapse: collapse;\">");
        sb.append("<tbody>");
        sb.append("<tr>");
        sb.append("<td style=\"width: 45%;text-align: left\">\n" +
                "\t\t\t\t\t\t\t\t<div style=\"padding-bottom: 5px\">\n" +
                "\t\t\t\t\t\t\t\t\t<span style=\"font-weight: bold;\">Delivery Note</span>\n" +
                "\t\t\t\t\t\t\t\t</div>\n" +
                "\t\t\t\t\t\t\t\t<div style=\"padding-bottom: 10px\">\n" +
                "\t\t\t\t\t\t\t\t\t<textarea rows=\"5\" cols=\"60\" readonly=\"\"style=\"border-radius: 5px; resize: none;\">"+(sysOrderMsg.getBuyerMsg()==null?"":sysOrderMsg.getBuyerMsg())+"</textarea>\n" +
                "\t\t\t\t\t\t\t\t</div>\n" +
                "\t\t\t\t\t\t\t</td>");

        sb.append("<th style=\"width: 55%; text-align: right;\">");
        sb.append("<table style=\"width: 100%; font-size:13px\">");
        sb.append("<tbody>");
        sb.append("<tr>\n" +
                "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%; text-align: left;\">Sub total</td>\n" +
                "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 5%\">:</td>\n" +
                "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 45%\"></td>\n" +
                "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%;\">RM "+sysOrderSupplier.getSubOriFee()+"</td>\n" +
                "\t\t\t\t\t\t\t\t\t\t</tr>");
        sb.append("<tr>\n" +
                "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%; text-align: left;\">Delivery Fee</td>\n" +
                "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 5%\">:</td>\n" +
                "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 45%\"></td>\n" +
                "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%;\">RM "+(sysOrderSupplier.getDeliveryFee()==null?"":sysOrderSupplier.getDeliveryFee())+"</td>\n" +
                "\t\t\t\t\t\t\t\t\t\t</tr>\n" +
                "\t\t\t\t\t\t\t\t\t\t<tr>\n" +
                "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%; text-align: left;\">Total (Incl. Tax)</td>\n" +
                "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 5%\">:</td>\n" +
                "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 45%\"></td>\n" +
                "\t\t\t\t\t\t\t\t\t\t\t<td style=\"width: 25%;\">RM "+sysOrderSupplier.getSubOriFee()+"</td>\n" +
                "\t\t\t\t\t\t\t\t\t\t</tr>");
        sb.append("</tbody>");
        sb.append("</table>");
        sb.append("</th>");
        sb.append("</tr>");
        sb.append("</tbody>");
        sb.append("</table>");
        sb.append("</div>");
        sb.append("<br>\n" +
                "\t\t\t<a href=SYSTEM_URL style=\"color: #2c84ea; font-weight: bold;\"> system_url </a>\n" +
                "\t\t\t<br>\n" +
                "\t\t\t<p>Need help? Contact \n" +
                "\t\t\t\t<strong> contact_no </strong> or send email to \n" +
                "\t\t\t\t<strong> general_email </strong> \n" +
                "\t\t\t\tfor system enquiry.\n" +
                "\t\t\t</p>\n" +
                "\t\t\t<br>\n" +
                "\t\t\t<p>Best regards,<br><strong>Airena Procure System</strong></p>");
        sb.append("</div>");
        sb.append("</div>");
        return sb;


    }
}
